package cn.stylefeng.guns.modular.rm;

import cn.stylefeng.guns.modular.rm.service.FbGameScoreService;
import cn.stylefeng.guns.modular.rm.service.FbGameService;
import cn.stylefeng.guns.modular.rm.service.RmGameScoreService;
import cn.stylefeng.guns.modular.rm.service.RmGameService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description TODO
 * @Author xiesm
 * @Date 2024/4/17 15:03
 **/
@RestController
public class FbController {
    @Autowired
    private FbGameScoreService fbGameScoreService;
    @Autowired
    private FbGameService fbGameService;

    @RequestMapping("/cp/saveFbGame")
    public String saveGame() {
        JSONObject body = fbGameService.getGames("0", null, 1);
        Integer total = body.getJSONObject("data").getInteger("pageTotal");
        for (int i = 1; i <= total; i++) {
            body = fbGameService.getGames("0", null, i);
            fbGameService.getGame(body);
        }
        return "ok";
    }

    @RequestMapping("/cp/saveFbGameScore")
    public String saveGameScore() {
        fbGameScoreService.getGameInfo();
        return "ok";
    }
}
